class MyPlugin {
  apply(compiler) {
    console.log('MyPlugins 起飞')
    compiler.hooks.emit.tap('MyPlugin', (complilation) => {
      // 此次打包过程中额上下文
      for (const name in complilation.assets) {
        if (name.endsWith('.js')) {
          const contents = compilation.assets[name].source()
          const withoutComments = contents.replace(/\/\*\*+\*\//g, '')
          compilation.assets[name] = {
            source: () => withoutComments,
            size: () => withoutComments.length,
          }
        }
      }
    })
  }
}
